using IBLL.Gzh;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace Web.Controllers
{
    public class YWController : Controller
    {
        IYWService _ys = BLLFactory.SetYWService();

        

        public JsonResult GetByIdToJson(int id)
        {
            if (id == null)
            {
                return Json(new { Result = "Fail" });
            }
            var data = _ys.GetEntityById(id);
            if (data == null)
            {
                return Json(new { Result = "Fail" });
            }
            return Json(data);
        }

        public IActionResult GetYwByYwlb(int ywlbId = 0)
        {
            var result = _ys.GetEntitysByLambdaAndSort(o => o.YwlbId == ywlbId, o=>o.SortIndex, true).ToList();
            return Json(result);
        }

        public IActionResult GetAllYwIsClys()
        {
            var result = _ys.GetEntitysByLambdaAndSort(o => o.IsClys, o => o.SortIndex, true).ToList();
            return Json(result);
        }

        
    }
}